



import os,sys
from pydantic import BaseModel, Field
from typing import List, Dict, Optional, Union
from pydantic_settings import BaseSettings, SettingsConfigDict 

cur_file = sys.argv[0]
env_file = ".env"
if cur_file.endswith('.py'):
    env_file = os.path.join(os.path.dirname(cur_file), ".env.development")
else:
    env_file = os.path.join(os.path.dirname(cur_file), ".env.production")
    
class ConfigsSchemas(BaseSettings):
    APP_NAME: str = Field(default="media_annotator", title="服务 host")
    SERVICE_HOST: str = Field(title="服务 host")
    SERVICE_PORT: int = Field(default=8000,title="服务端口")
    REDIS_PORT: int = Field(default=6379,title="redis 端口")
    REDIS_PASSWORD: str = Field(title="redis 密码")
    REDIS_DB: int = Field(default=1,title="redis 数据库")
    DEBUG: bool = Field(default=False,title="是否开启调试模式")
    IMAGES_DOWNLOAD_BASE_URL:str = Field(title="图片下载地址")
    model_config = SettingsConfigDict(  
        env_file=env_file,  
        extra="allow"  
    )  
    
    
configs = ConfigsSchemas() # 读取配置文件
    